//1.公共样式
require('../../assets/css/index.less');

//2.当前页面样式
require('./login.less');

//3.公用js
let dom = require('../../utils/dom.js');
let https = require('../../utils/https.js');
let local=require('../../utils/local.js');

//4.当前页面的js
dom.ready(function () {
    //登录功能
    dom.getById('#btn').addEventListener('click', function () {
        if (account.value == '') {//判定账号--非空验证
            alert('账号不能为空')
        } else if (password.value == "") {
            alert('密码不能为空')
        } else {
            https.post('/api/user/login', {
                account: account.value,
                password: password.value
            }, function (res) {
                if (res.errno == 0) {
                    localStorage.setItem('tk',res.data.token)
                    window.location.href ='home.html'
                } else {
                    alert(res.message)
                }
            })
        }
    })

})